﻿import pandas as pd
cleanedfile = './temp/data_cleaned.xls'
zscorefile = './temp/zscorefile.xls'
data = pd.read_excel(cleanedfile , encoding = 'utf-8')
data = data[['LOAD_TIME','FFP_DATE','LAST_TO_END','FLIGHT_COUNT','SEG_KM_SUM','avg_discount']]

d = pd.to_datetime(data['LOAD_TIME'])-pd.to_datetime(data['FFP_DATE'])
f = lambda x:x.days/30
L = d.apply(f)
zscore = pd.DataFrame({'L':L,'R':data['LAST_TO_END'],'F':data['FLIGHT_COUNT'],'M':data['SEG_KM_SUM'],'C':data['avg_discount']})
zscore.to_excel(zscorefile)